/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package nite.gestures;

import com.primesense.NITE.*;
import org.OpenNI.IObservable;
import org.OpenNI.IObserver;
import org.OpenNI.Point3D;

/**
 *
 * @author xvanek9
 */
public class AbstractGesture {
        public class ActivateObserver implements IObserver<NullEventArgs> {
        @Override
        public void update(IObservable<NullEventArgs> io, NullEventArgs args) {
            System.out.println("Wave observer activated");
        }
    }
    
    public class DeactivateObserver implements IObserver<NullEventArgs>{
        @Override
        public void update(IObservable<NullEventArgs> io, NullEventArgs args) {
            System.out.println("Observer deactivated.");
        }
    }    

    public class MessageUpdateObserver implements IObserver<PointerEventArgs> {
        @Override
        public void update(IObservable<PointerEventArgs> io, PointerEventArgs args) {
            // crazy stuff :)
            //System.out.println(args.getPointer());
        }
    }    

    public class NoPointsObserver implements IObserver<NullEventArgs> {

        @Override
        public void update(IObservable<NullEventArgs> io, NullEventArgs args) {
            System.out.println("No points in the scene");
        }

    }    
    
    public class PointCreateObserver implements IObserver<HandEventArgs> {

        @Override
        public void update(IObservable<HandEventArgs> io, HandEventArgs args) {
            System.out.println("Hand created at: " + args.getHand().getPosition().getX() + ", "
            + args.getHand().getPosition().getY() + ", " + args.getHand().getPosition().getZ()
                    );
        }

    }    
    
    public class PointDestroyObserver implements IObserver<IdEventArgs> {

        @Override
        public void update(IObservable<IdEventArgs> io, IdEventArgs args) {
            System.out.println("Point " + args.getId() +" destroyed." );
        }

    }    
    
    public class PointUpdateObserver implements IObserver<HandEventArgs>{

        @Override
        public void update(IObservable<HandEventArgs> io, HandEventArgs args) {
//            System.out.println("Point position: " + args.getHand().getPosition().getX() + ", "
//                     + args.getHand().getPosition().getY() + ", "
//                     + args.getHand().getPosition().getZ()
//                    );
        }
        
        PointUpdateObserver getPointUpdateObserver(){
            return this;
        }
        

    }    
    
    public class PrimaryPointCreateObserver implements IObserver<HandPointEventArgs> {
        @Override
        public void update(IObservable<HandPointEventArgs> io, HandPointEventArgs args) {
            System.out.println("Primary point created at: " + args.getHand().getPosition().getX() + ", "
                    + args.getHand().getPosition().getY() + ", "
                    + args.getHand().getPosition().getZ()
                    );
        }

    }    
    
    public class PrimaryPointDestroyObserver implements IObserver<IdEventArgs>{

        @Override
        public void update(IObservable<IdEventArgs> io, IdEventArgs args) {
            System.out.println("Point " + args.getId() + " destroyed.");
        }

    }    
    
    public class PrimaryPointReplaceObserver implements IObserver<HandIdEventArgs> {

        @Override
        public void update(IObservable<HandIdEventArgs> io, HandIdEventArgs args) {
            System.out.print("Point " +args.getHand().getID() + " replaced.");
        }

    }    
    
    public class PrimaryPointUpdateObserver implements IObserver<HandEventArgs>{

        Point3D position;
        
        @Override
        public void update(IObservable<HandEventArgs> io, HandEventArgs args) {
            //System.out.print("Point " + args.getHand().getID() + " updated.");
            updatePosition(args.getHand().getPosition());
        }
        
        public void updatePosition(Point3D pos){
            position = pos;
        }

        public Point3D getPosition() {
            if (position != null){
            return position;}
            else
            {
                return new Point3D(0,0,0);
            }
        }
        
    }    
}
